<?php
$type_photo     = 'product';

if($actPost=="updatephotos")
{
    $listurl		= gpc_getStringArray("ListUrl");
    $listname		= gpc_getStringArray("ListName");
    $listid			= gpc_getStringArray("ListId");
    $listorder		= gpc_getStringArray("listorder");
    $ParentId       = gpc_getIntPost('ParentId');

    foreach($listid as $i=> $id)
    {
        $id=intval($id);
        if($listurl[$i]==-1 && $id>0)
        {
            DeleteImages($id);
        }
        elseif($id<=0)
        {
        	InsertImages($listname[$i],$listurl[$i],1,$type_photo,$ParentId);
        }
        else
        {
            UpdateImages($listname[$i],$listorder[$i],$id);
        }
    }
    page_transfer("Photos of product Saved");
}else
{
    $listphotos = ListImagesByType($type_photo,$id);
    $product    = LoadProductById($id);
    $parentname = $product['cName'];
}
?>